package cn.gs.serializable.old;

// @author gs
public class SerialTransport {
    
    public static String encode(String str) {
        String s= str.replace("\\", "\\\\").replace("\"", "\\\"").replace("/", "\\/")
                .replace("\b", "\\b").replace("\f", "\\f").replace("\n", "\\n")
                .replace("\r", "\\r").replace("\t", "\\t");
        return s;
    }
     
    public static String decode(String str) {
        String s= str.replace("\\\\", "\\m").replace("\\t", "\t").replace("\\r", "\r")
                .replace("\\n", "\n").replace("\\f", "\f").replace("\\b", "\b")
                .replace("\\/", "/").replace("\\\"", "\"").replace("\\m", "\\");
        return s;
    }
}
